﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Newtonsoft.Json.Linq;
using System.Data;
using System.Web;
using System.Web.Hosting;
using System.IO;
using Oracle.ManagedDataAccess.Client;

namespace XBJCYGC.Controllers
{
    public class MainController : ApiController
    {
        [HttpPost]
        [CYGCExceptionFilter("获取菜单及组织单位时错误")]
        public DataTable getMainmenu(JObject opt)
        {
            OracleParameter[] para = new OracleParameter[1]{
                new OracleParameter("username",opt["name"].ToString())
            };
            return DB.CYGC.Query(@"SELECT id, pid, title NAME, connect_by_isleaf isleaf, url
  FROM sys_menu
 WHERE id IN
	   (SELECT menuid FROM sys_user u, sys_role r WHERE u.yhrole = r.role and u.name=:username)
CONNECT BY pid = PRIOR id
 START WITH pid IS NULL
 ORDER BY px",para);
        }
    }
}
